package developer.zyk.global.config;


import jakarta.annotation.PostConstruct;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Data
@Slf4j
public class PlatFormProperties {
    private AliYun aliYun;
    private AliBaiLian aliBaiLian;
    private TengXun tengXun;

    @PostConstruct
    public void init() {
        AliYun aly = new AliYun();
        aly.setAccessId(getEnv("ALIYUN_ACCESS_ID"));
        aly.setAccessKey(getEnv("ALIYUN_ACCESS_KEY"));
        aly.setEndpoint(getEnv("ALIYUN_ENDPOINT"));
        this.aliYun = aly;
        log.info("阿里云配置完成:{}", this.aliYun);
        AliBaiLian baiLian = new AliBaiLian();
        baiLian.setApiKey(getEnv("ALIBAILIAN_API_KEY"));
        baiLian.setEmbeddingModel(getEnv("ALIBAILIAN_EMBEDDING_MODEL"));
        baiLian.setEmbeddingUrl(getEnv("ALIBAILIAN_EMBEDDING_URL"));
        baiLian.setBaseUrl(getEnv("ALIBAILIAN_BASE_URL"));
        this.aliBaiLian = baiLian;
        log.info("阿里百练配置完成:{}", this.aliBaiLian);

        TengXun tx = new TengXun();
        tx.setSecretId(getEnv("TENGXUN_SECRET_ID"));
        tx.setSecretKey(getEnv("TENGXUN_SECRET_KEY"));
        this.tengXun = tx;
        log.info("腾讯oss配置完成:{}", this.tengXun);

    }

    @Data
    public static class AliYun {
        private String accessId;
        private String accessKey;
        private String endpoint;


    }

    @Data
    public static class AliBaiLian {
        private String apiKey;
        private String baseUrl;
        private String embeddingModel;
        private String embeddingUrl;

    }

    @Data
    public static class TengXun {
        private String secretId;
        private String secretKey;

    }

    private static String getEnv(String key) {
        return System.getenv(key);
    }


}
